package com.kk.xhr.model.dao;

import static com.kk.xhr.model.dao.PrizeExperienceDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.kk.xhr.model.entity.PrizeExperience;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface PrizeExperienceMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    BasicColumn[] selectList = BasicColumn.columnList(id, employeeId, title, content, fileId, awardTime);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="record.id", before=false, resultType=Long.class)
    int insert(InsertStatementProvider<PrizeExperience> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("PrizeExperienceResult")
    Optional<PrizeExperience> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="PrizeExperienceResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="employee_id", property="employeeId", jdbcType=JdbcType.BIGINT),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR),
        @Result(column="file_id", property="fileId", jdbcType=JdbcType.VARCHAR),
        @Result(column="award_time", property="awardTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<PrizeExperience> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, prizeExperience, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, prizeExperience, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    default int deleteByPrimaryKey(Long id_) {
        return delete(c -> 
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    default int insert(PrizeExperience record) {
        return MyBatis3Utils.insert(this::insert, record, prizeExperience, c ->
            c.map(employeeId).toProperty("employeeId")
            .map(title).toProperty("title")
            .map(content).toProperty("content")
            .map(fileId).toProperty("fileId")
            .map(awardTime).toProperty("awardTime")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    default int insertSelective(PrizeExperience record) {
        return MyBatis3Utils.insert(this::insert, record, prizeExperience, c ->
            c.map(employeeId).toPropertyWhenPresent("employeeId", record::getEmployeeId)
            .map(title).toPropertyWhenPresent("title", record::getTitle)
            .map(content).toPropertyWhenPresent("content", record::getContent)
            .map(fileId).toPropertyWhenPresent("fileId", record::getFileId)
            .map(awardTime).toPropertyWhenPresent("awardTime", record::getAwardTime)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    default Optional<PrizeExperience> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, prizeExperience, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    default List<PrizeExperience> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, prizeExperience, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    default List<PrizeExperience> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, prizeExperience, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    default Optional<PrizeExperience> selectByPrimaryKey(Long id_) {
        return selectOne(c ->
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, prizeExperience, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    static UpdateDSL<UpdateModel> updateAllColumns(PrizeExperience record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(employeeId).equalTo(record::getEmployeeId)
                .set(title).equalTo(record::getTitle)
                .set(content).equalTo(record::getContent)
                .set(fileId).equalTo(record::getFileId)
                .set(awardTime).equalTo(record::getAwardTime);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(PrizeExperience record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(employeeId).equalToWhenPresent(record::getEmployeeId)
                .set(title).equalToWhenPresent(record::getTitle)
                .set(content).equalToWhenPresent(record::getContent)
                .set(fileId).equalToWhenPresent(record::getFileId)
                .set(awardTime).equalToWhenPresent(record::getAwardTime);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    default int updateByPrimaryKey(PrizeExperience record) {
        return update(c ->
            c.set(employeeId).equalTo(record::getEmployeeId)
            .set(title).equalTo(record::getTitle)
            .set(content).equalTo(record::getContent)
            .set(fileId).equalTo(record::getFileId)
            .set(awardTime).equalTo(record::getAwardTime)
            .where(id, isEqualTo(record::getId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: prize_experience")
    default int updateByPrimaryKeySelective(PrizeExperience record) {
        return update(c ->
            c.set(employeeId).equalToWhenPresent(record::getEmployeeId)
            .set(title).equalToWhenPresent(record::getTitle)
            .set(content).equalToWhenPresent(record::getContent)
            .set(fileId).equalToWhenPresent(record::getFileId)
            .set(awardTime).equalToWhenPresent(record::getAwardTime)
            .where(id, isEqualTo(record::getId))
        );
    }
}